<?php  
class Mlog extends CI_model{ 
     // đếm tổng số record trong table book 
    public function count_all(){ 
        return $this->db->count_all('log'); 
    }
    public function listall(){
        
		$this->db->order_by("userlog_id", "desc"); 
		$query=$this->db->get("log");
        return $query->result_array();
    }

    public function Insert($data) {
        $this->db->insert('log',$data);
        return $this->db->insert_id();
    }

    public function Delete($id) {
    	$data = $this->Getlog($id);
    	$this->db->where('HinhAnh_id', $id);
    	$this->db->delete('log');
    	$pathImage = 'public/frontend/images/hosrem/'.$data->urlHinh;
    	@unlink($pathImage);

    }
 public function GetAlbumsActive(){
        $this->db->where("Active",1);
        $query=$this->db->get('log');
       $query=$this->db->get("log");
        return $query->result_array();
    }
     public function Getlog($id){
        $this->db->where("HinhAnh_id",$id);
        $query=$this->db->get('log');
        $data = $query->row();
        return $data; 
    }
}